package com.cwj.vm;

import java.util.*;

/**
 * @author chenwujie
 * @date 2021-02-24 10:57
 */
public class ParallelScavengeGcTest {
    private static final int _1MB = 1024 * 1024;
    /**
     * vm options: -Xms400m -Xmx400m -Xmn100m -XX:SurvivorRatio=8 -XX:+PrintGCDetails
     * @param args
     */
    public static void main(String[] args) {
        Map<Integer, Object> map = new HashMap<>();
        while (true){
            try {
                Thread.sleep(5_000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            List<byte[]> bytes0 = m1(20);
            List<byte[]> bytes1 = m1(20);
            List<byte[]> bytes2 = m1(20);
            List<byte[]> bytes3 = m1(40);

            Random random = new Random();
            int i = random.nextInt(300);
            map.put(i, bytes0);
        }
    }

    public static List<byte[]> m1(int mb){
        List<byte[]> list = new ArrayList<>();
        for (int i = 0; i < mb; i++) {
            list.add(new byte[_1MB]);
        }
        return list;
    }
}
